<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>更换电表数据列表</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link rel="stylesheet" type="text/css" href="../bootstrap/dist/css/bootstrap.min.css" />
		<link rel="stylesheet" type="text/css" href="../css/bootstrap-datetimepicker.min.css" />
		<link rel="stylesheet" href="../css/fileinput.min.css" />
		<link rel="stylesheet" type="text/css" href="../css/public.css" />
	</head>
	<style type="text/css">
		.remove {
			cursor: pointer;
		}
		
		.remove:hover {
			/*color: red;*/
		}
		
		.pagination span {
			font: 14px/34px "";
			padding: 0 5px;
		}
		
		.form-control {
			display: inline-block;
			width: 120px;
		}
		
		.search {
			width: 155px;
		}
		
		.header {
			/*border-bottom: 1px solid #fefefe;*/
		}
		
		.header span {
			padding: 0 5px;
		}
		
		ul {
			display: block;
			list-style-type: disc;
			margin-block-start: 0em;
			margin-block-end: 0em;
			margin-inline-start: 0px;
			margin-inline-end: 0px;
			padding-inline-start: 0px;
		}
		
		li {
			list-style-type: none;
			display: flex;
			justify-content: flex-start;
			border-bottom: 1px solid #ebebeb;
			font: 14px/28px "";
		}
		
		li span {
			display: inline-block;
			width: 20%;
		}
		
		.table_cla {
			height: 560px;
		}
	</style>

	<body>
		<div id="app" style="width: 100%; margin: 0 auto;padding:0 20px;">
			<div class="header" style="margin-top: 20px;">
				<!--<span>楼宇：</span>-->
				<select name="" class="form-control" v-model="build_model" @change="buildchange">
					<option v-for="index in build" :value="index.id" v-text="index.buildname"></option>
				</select>
				<!--<span>单元：</span>-->
				<select name="" class="form-control" v-model="unit_model" @change="unitchange">
					<option v-for="index in unit" :value="index.id" v-text="index.unitname"></option>
				</select>
				<!--<span>楼层：</span>-->
				<select name="" class="form-control" v-model="floor_model" @change="floorchange">
					<option v-for="index in floor" :value="index.id" v-text="index.floorname"></option>
				</select>
				<!--<span>房号：</span>-->
				<select name="" class="form-control" v-model="room_model">
					<option v-for="index in room" :value="index.rommid" v-text="index.rommcode"></option>
				</select>
				<!--<select name="" class="form-control" v-model="rechresult">
					<option v-for="index in leixing" :value="index.id" v-text="index.name"></option>
				</select>-->
				<input style="width: 155px;" type="text" class="form-control" name="search1" id="search1" value="" v-model="searchmain" placeholder="请输入需要搜索的信息" />
				<button type="button" class="btn btn-info" data-dismiss="modal" @click="search">搜索</button>
				<!--<button type="button" class="btn btn-info" data-toggle="modal" data-target="#add_water_meter" @click="add_water_meter">添加水表</button>-->
			</div>
			<div class="table_cla">
				<table class="table">
					<caption>查询电表换表列表</caption>
					<thead>
						<tr>
							<th>楼宇名称</th>
							<th>单元号</th>
							<th>楼层</th>
							<th>房间号</th>
							<th>业主</th>
							<th>新表号</th>
							<th>更换时间</th>
							<th>更换人</th>
							<th>初始充量</th>
							<th>操作 </th>
						</tr>
					</thead>
					<tbody>
						<tr v-for="(tt,index) in table">
							<td v-text="tt.buildname"></td>
							<td v-text="tt.units"></td>
							<td v-text="tt.floor"></td>
							<td v-text="tt.rommcode"></td>
							<td v-text="tt.custname"></td>
							<td v-text="tt.watchno"></td>
							<td v-text="tt.createdate"></td>
							<td v-text="tt.createusername"></td>
							<td v-text="tt.initsum"></td>
							<td class="remove">
								<span v-if="panduan" data-toggle="modal" data-target="#myModalremove" style="color: #286090;" @click="sure_more(tt)" class="glyphicon glyphicon-align-justify">详情&nbsp;</span>
								<!--<span v-if="panduan" @click="fix_water_meter(tt)" data-toggle="modal" data-target="#fix_water_meter" style="color: #f0ad4e;" class="glyphicon glyphicon-pencil">修改&nbsp;</span>
								<span v-if="panduan" data-toggle="modal" data-target="#remove_water_meter" @click="remove_water_meter(tt)" style="color: #d43f3a;" class="glyphicon glyphicon-trash">删除&nbsp;</span>
								<span v-if="panduan" @click="replace_water_meter(tt)" data-toggle="modal" data-target="#replace_water_meter" style="color: #5bc0de;" class="glyphicon glyphicon-refresh">换表&nbsp;</span>
							-->
							</td>
						</tr>
					</tbody>
				</table>
			</div>
			<ul class="pagination">
				<span v-text="count_all"></span>
				<!--<li v-show="current != 1" @click="current-- && goto(current--)">
					<a href="#">上一页</a>
				</li>-->
				<li v-for="index in pages" @click="goto(index)" :class="{'active':current == index}" :key="index">
					<a href="#" v-text="index"></a>
				</li>
				<!--<li v-show="allpage != current && allpage != 0 " @click="current++ && goto(current++)">
					<a href="#">下一页</a>
				</li>-->
				<span>跳到:</span>
				<input style="width: 50px;height: 28px;" name="goto" id="goto" v-model="jump" type="text" name="" oninput="value=value.replace(/[^\d]/g,'')">
				<!--<input style="width: 50px;height: 34px;" min="1" max="{{allpage}}" type="number" name="goto" id="goto" v-model="jump" />-->
				<span>页</span>
				<button type="button" id="gotoo" @click="goto(jump)" class="btn btn-danger ">确定 </button>
			</ul>
			<!-- 模态框（Modal）详情 -->
			<div class="modal fade" id="myModalremove" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
							<h4 class="modal-title" id="myModalLabel">水表换表详情</h4>
						</div>
						<div class="modal-body">
							<ul id="te_ul">
								<li>
									<span>表具id:</span><label v-text="model_data.equipsid"></label>
								</li>
								<li>
									<span>更换时间:</span><label v-text="model_data.createdate"></label>
								</li>
								<li>
									<span>厂商名 :</span><label v-text="model_data.factoryid"></label>
								</li>
								<li>
									<span>安装位置: </span><label v-text="model_data.instadr"></label>
								</li>
								<li v-if="model_data.oldwatchpic">
									<span>旧表照片 :</span><img data-action="zoom" :src="model_data.oldwatchpic" alt="旧表照片" />
								</li>
								<li>
									<span>备注 :</span><textarea v-text="model_data.remarks"></textarea>
								</li>
								<li>
									<span>旧表号 :</span><label v-text="model_data.oldwatchno"></label>
								</li>

							</ul>
						</div>
						<div v-if="kind==1" class="modal-footer">
							<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
							<!--<button type="button" class="btn btn-danger remove" @click="surepay">确定充值</button>-->
						</div>
						<div v-if="kind==2" class="modal-footer">
							<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
							<!--<button type="button" id="water_meter_open" @click="water_meter_open" class="btn btn-info remove">开阀</button>
							<button type="button" id="water_meter_close" @click="water_meter_close" class="btn btn-info remove">关阀</button>
							<button type="button" id="meter_info_search" @click="meter_info_search" data-toggle="modal" data-target="#myModal_meter_info" @click="meter_info_search" class="btn btn-info remove">读水表数据</button>
						-->
						</div>

					</div>
					<!-- /.modal-content -->
				</div>
				<!-- /.modal -->
			</div>
			<!-- 模态框（Modal）提示信息 -->
			<div class="modal fade" id="myModal_tips" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
							<h4 class="modal-title" id="myModalLabel">提示信息</h4>
						</div>
						<div class="modal-body" id="tips" v-text="tips_modal">

						</div>
						<div class="modal-footer">
							<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
						</div>
					</div>
				</div>
			</div>

		</div>
	</body>

</html>
<script src="../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/vue.js" type="text/javascript" charset="utf-8"></script>
<script src="../bootstrap/dist/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/public.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/zooming.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
	$(function() {
		$("#Form1 .file-drop-zone-title").html("上传旧表照片");
	})
</script>
<script>
	new Vue({
		el: '#app',
		data: {
			urlr: "",
			yanli_url: '',
			current: 1,
			showItem: 5,
			rechresult: "",
			allpage: "",
			jump: "",
			userid: "",
			count_all: '',
			model_data: "",
			show_caozuo: false,
			tips_modal: "",
			vendor: "",
			kind: 0,
			areaid: "",
			instdate: "",
			searchmain: "",
			panduan: true,
			token: "",
			merchantid: "",
			goodsid: '',
			imgpath: "",
			imgpath1: "",
			leixing_model: "",
			payid: "",
			issetprice: [{
				id: 1,
				value: '单价'
			}, {
				id: 2,
				value: '阶梯价'
			}, ],
			lou: [{
				buildname: '请选择楼宇',
				id: ""
			}],
			lou_model: "",
			danyuan: [{
				unitname: '请选择单元',
				id: ""
			}],
			danyuan_model: '',
			table: [{}, ],
			data_remove: {},
			build: [{
				buildname: '请选择楼宇',
				id: ""
			}],
			build_model: "",
			unit: [{
				unitname: '请选择单元',
				id: ""
			}],
			unit_model: '',
			floor: [{
				floorname: '请选择楼层',
				id: ""
			}],
			floor_model: '',
			room: [{
				rommcode: '请选择房号',
				rommid: ""
			}],

			room_model: '',
		},
		//计算属性
		computed: {

		},
		created: function() {
			var that = this;
			that.yanli_url = getUrl_yangli();
			that.urlr = getUrl();
			that.get_upload = get_upload();
			that.build_model = that.build[0].id;
			that.unit_model = that.unit[0].id;
			that.floor_model = that.floor[0].id;
			that.room_model = that.room[0].rommid;
		},
		mounted: function() {
			var that = this;
			this.lou_model = this.lou[0].id;
			this.danyuan_model = this.danyuan[0].id;
			var userid = getUrlParam('userid');
			this.userid = userid;
			var createusername = getUrlParam('realname');
			this.createusername = createusername;
			var merchantid = getUrlParam('merchantid');
			this.merchantid = merchantid;
			var areaid = getUrlParam('areaid');
			this.areaid = areaid;
			var token = getUrlParam('token');
			this.token = token;
			var goodsid = getUrlParam('goodsid');
			this.goodsid = goodsid;
			if(userid == null || userid == '') {
				this.tips_modal = "用户id不能为空";
				$('#myModal_tips').modal('show');
				this.val_te = true;
				return;
			}
			if(createusername == null || createusername == '') {
				this.tips_modal = "用户姓名不能为空";
				$('#myModal_tips').modal('show');
				this.val_te = true;
				return;
			}
			if(areaid == null || areaid == '') {
				this.tips_modal = "小区id不能为空";
				$('#myModal_tips').modal('show');
				this.val_te = true;
				return;
			}
			if(merchantid == null || merchantid == '') {
				this.tips_modal = "物业id不能为空";
				$('#myModal_tips').modal('show');
				this.val_te = true;
				return;
			}
			if(merchantid == null || merchantid == '') {
				this.tips_modal = "物业id不能为空";
				$('#myModal_tips').modal('show');
				this.val_te = true;
				return;
			}
			if(goodsid == null || goodsid == '') {
				this.tips_modal = "goodsid不能为空";
				$('#myModal_tips').modal('show');
				this.val_te = true;
				return;
			}
			that.build_model = that.build[0].id;
			that.unit_model = that.unit[0].id;
			that.floor_model = that.floor[0].id;
			that.room_model = that.room[0].rommid;

			var datainit = {
				pagenumber: 1,
				pagesize: 10,
				areaid: this.areaid,
				buildid: this.build_model,
				unitid: this.unit_model,
				rommid: this.room_model,
				floor: this.floor_model,
				selectinfo: this.searchmain,
			};
			if(this.val_te != true) {
				this.jiazai(datainit);
				this.lou_info(this.areaid)
				this.table = ""
			}
		},
		computed: {
			pages: function() {
				var pag = [];
				if(this.current < this.showItem) { //如果当前的激活的项 小于要显示的条数
					//总页数和要显示的条数那个大就显示多少条
					var i = Math.min(this.showItem, this.allpage);
					while(i) {
						pag.unshift(i--);
					}
				} else { //当前页数大于显示页数了
					var middle = this.current - Math.floor(this.showItem / 2), //从哪里开始
						i = this.showItem;
					if(middle > (this.allpage - this.showItem)) {
						middle = (this.allpage - this.showItem) + 1
					}
					while(i--) {
						pag.push(middle++);
					}
				}
				return pag
			},
		},
		methods: {
			//提示
			tips: function(data) {
				var that = this;
				that.tips_modal = data;
				$('#myModal_tips').modal('show');
			},
			//获取楼宇
			lou_info: function(areaid) {
				var that = this;
				var data = JSON.stringify({
					parentid: that.areaid
				})
				$.ajax({
					contentType: "application/json; charset=utf-8",
					type: "POST",
					url: that.urlr + "/public/selectBuildList",
					data: data,
					async: true,
					dataType: "json",
					success: function(msg) {
						//						console.log(msg);
						if(msg.code == 200) {
							var aa = JSON.parse(msg.returnString);
							var te = {
								buildname: '请选择楼宇',
								id: ""
							}
							aa.unshift(te);
							that.build = aa;
							that.build_model = that.build[0].id;
						} else {
							//							alert(msg.disp)
							that.tips_modal = msg.disp;
							$('#myModal_tips').modal('show');
						}
					},
					error: function() {
						//						alert("获取信息失败");
						that.tips_modal = "获取信息失败";
						$('#myModal_tips').modal('show');
					}
				});
			},
			//楼改变请求单元
			buildchange: function() {
				this.unil_info(this.build_model);
			},
			//获取单元
			unil_info: function(areaid) {
				if(areaid != "") {
					var that = this;
					var data = JSON.stringify({
						parentid: areaid
					})
					$.ajax({
						contentType: "application/json; charset=utf-8",
						type: "POST",
						url: that.urlr + "/public/selectUnitsList",
						data: data,
						async: true,
						dataType: "json",
						success: function(msg) {
							//							console.log(msg);
							if(msg.code == 200) {
								var aa = JSON.parse(msg.returnString);
								var te = {
									unitname: '请选择单元',
									id: ""
								}
								aa.unshift(te);
								that.unit = aa;
								that.unit_model = that.unit[0].id;
							} else {
								//							alert(msg.disp)
								that.tips_modal = msg.disp;
								$('#myModal_tips').modal('show');
							}
						},
						error: function() {
							//						alert("获取信息失败");
							that.tips_modal = "获取信息失败";
							$('#myModal_tips').modal('show');
						}
					});
				}

			},
			/*单元改变*/
			unitchange: function() {
				this.floor_info(this.unit_model);
			},
			//获取楼层
			floor_info: function(areaid) {
				if(areaid != "") {
					var that = this;
					var data = JSON.stringify({
						parentid: areaid
					})
					$.ajax({
						contentType: "application/json; charset=utf-8",
						type: "POST",
						url: that.urlr + "/public/selectFloors",
						data: data,
						async: true,
						dataType: "json",
						success: function(msg) {
							//							console.log(msg);
							if(msg.code == 200) {
								var aa = JSON.parse(msg.returnString);
								var te = {
									floorname: '请选择楼层',
									id: ""
								}
								var flloor = [];
								for(var i = 1; i <= aa; i++) {
									var main = {
										floorname: i + "层",
										id: i
									}
									flloor.push(main)
								}
								flloor.unshift(te);
								that.floor = flloor;
								that.floor_model = that.floor[0].id;
							} else {
								//							alert(msg.disp)
								that.tips_modal = msg.disp;
								$('#myModal_tips').modal('show');
							}
						},
						error: function() {
							//						alert("获取信息失败");
							that.tips_modal = "获取信息失败";
							$('#myModal_tips').modal('show');
						}
					});
				}

			},
			//楼层改变
			floorchange: function() {
				var that = this;
				if(this.unit_model == '' || this.floor_model == '') {
					var aa = [];
					var te = {
						rommcode: '请选择房号',
						rommid: ""
					}
					aa.unshift(te);
					that.room = aa;
					that.room_model = that.room[0].rommid;
				} else {
					this.room_info(this.unit_model, this.floor_model);
				}
			},
			//出现房屋
			room_info: function(areaid, floor_c) {
				if(areaid != "" || floor_c != "") {
					var that = this;
					var data = JSON.stringify({
						parentid: areaid,
						floor: floor_c
					})
					$.ajax({
						contentType: "application/json; charset=utf-8",

						type: "POST",
						url: that.urlr + "/public/selectRoomCodeList",
						data: data,
						async: true,
						dataType: "json",
						success: function(msg) {
							//							console.log(msg);
							if(msg.code == 200) {
								var aa = JSON.parse(msg.returnString);
								var te = {
									rommcode: '请选择房号',
									rommid: ""
								}
								aa.unshift(te);
								that.room = aa;
								that.room_model = that.room[0].rommid;
							} else {
								that.tips_modal = msg.disp;
								$('#myModal_tips').modal('show');
							}
						},
						error: function() {
							that.tips_modal = "获取信息失败";
							$('#myModal_tips').modal('show');
						}
					});
				}
			},
			//加载数据
			jiazai: function(e) {
				//				console.log(e)			
				var data = JSON.stringify(e);
				var that = this;
				$.ajax({
					contentType: "application/json; charset=utf-8",
					type: "POST",
					url: that.urlr + "/verify/elepro/selectEleUpdateRecord",
					data: data,
					headers: {
						"userid": that.userid,
						"token": that.token
					},
					async: true,
					dataType: "json",
					success: function(msg) {
												console.log(msg);
						if(msg.code == 200) {
							var data = JSON.parse(msg.returnString);
							//														console.log(data);
							for(var i = 0; i < data.length; i++) {
								if(data[i].watchstate == 1) {
									data[i].watchstate = '正常'
								} else if(data[i].watchstate == 2) {
									data[i].watchstate = "未开闸 "
								}
							}
							that.table = data;
							that.count_all = "共" + msg.count + "条"
							var yu = msg.count % 10;
							if(yu == 0) {
								that.allpage = parseInt(msg.count / 10);
							} else {
								that.allpage = parseInt(msg.count / 10) + 1;
							}

						} else {
							that.tips_modal = msg.disp;
							$('#myModal_tips').modal('show');
						}
					},
					error: function() {
						//						alert("获取信息失败");
						that.tips_modal = "获取信息失败";
						$('#myModal_tips').modal('show');
					}
				});

			},
			//跳页
			goto: function(index) {
				if(index == this.current) return;
				if(index > this.allpage) {
					return
				}
				//				debugger
				var re = /^[1-9]+[0-9]*]*$/ //判断正整数      // /^[0-9]+.?[0-9]*$/; //判断字符串是否为数字  
				if(!re.test(index)) {
					return false;
				}
				this.current = index; 
				
				var datainit = {
					pagenumber: index,
					pagesize: 10,
					areaid: this.areaid,
					buildid: this.build_model,
					unitid: this.unit_model,
					rommid: this.room_model,
					floor: this.floor_model,
					selectinfo: this.searchmain,

				};

				this.jiazai(datainit);
				//这里可以发送ajax请求
			},
			search: function() {
				var that = this;
				var datainit = {
					pagenumber: 1,
					pagesize: 10,
					areaid: this.areaid,
					buildid: this.build_model,
					unitid: this.unit_model,
					rommid: this.room_model,
					floor: this.floor_model,
					selectinfo: this.searchmain,
				}
				if(that.val_te != true) {
					this.jiazai(datainit);
					that.current=1;
				} else {
					//					alert("非法登录");
					that.tips_modal = "非法登录";
					$('#myModal_tips').modal('show');
				}
			},
			sure_more: function(data) {
				var that = this;
				that.model_data = data;
				console.log(that.model_data.equipsid);
				var data = JSON.stringify({
					equipsid: that.model_data.equipsid
				});
				$.ajax({
					contentType: "application/json; charset=utf-8",
					type: "POST",
					url: that.urlr + "/verify/watermeter/selectWaterInfo",
					data: data,
					headers: {
						"userid": that.userid,
						"token": that.token
					},
					async: true,
					dataType: "json",
					success: function(msg) {
						if(msg.code == 200) {
							var data_msg = JSON.parse(msg.returnString);
							that.kind = data_msg.kind;
							console.log(that.kind);
						} else {
							that.tips_modal = msg.disp;
							$('#myModal_tips').modal('show');
						}
					},
					error: function() {
						that.tips_modal = "获取信息失败";
						$('#myModal_tips').modal('show');
					}
				});
			},

		},

	})
</script>